package com.ce.pms.log4ce;

import java.util.Map;

import org.aspectj.lang.JoinPoint;

import com.ce.component.log4ce.aop.constructor.support.AbstractBizDescriptionHandler;
import com.ce.component.log4ce.aop.constructor.support.BizDescriptionHandler;
import com.ce.component.log4ce.aop.parser.BizLogParser;
import com.ce.pms.house.model.HousePlan;
import com.ce.pms.house.vo.FlatVO;


public class HouseAddHandler extends AbstractBizDescriptionHandler implements BizDescriptionHandler {

	private Log4ceHelper log4ceHelper = Log4ceHelper.getInstance();

	@Override
	public Map<String, Object> getNamedParametersMap(JoinPoint joinPoint, Object returnValue, BizLogParser logParser) {

		Map<String,Object> map = logParser.getLogArguments(joinPoint);

		//获取被代理方法的参数
		FlatVO flatvo = (FlatVO)returnValue;//(FlatVO) map.get("flatvo");

		Long planId = flatvo.getHousePlanId();
		HousePlan housePlan = log4ceHelper.getHouseService().getHousePlanByPlanId(planId);

		FlatVO house = log4ceHelper.getFlatVOById(flatvo.getKeyword());
		//记录新的房间信息，此map中的key值须与log4ce.globalMessageResource资源文件中定义的{}中的名字一致
		map.put("houseNumber", flatvo.getHouseNumber());
		map.put("houseType", housePlan.getName());
		map.put("standard", house.getDeliveryLimitationName());
		map.put("buildSize", flatvo.getBuildSize());
		map.put("innerSize", flatvo.getInnerSize());
		map.put("publicSize", flatvo.getPublicSize());

		map.putAll(logParser.getLogStaticContents(joinPoint));

		return map;
	}
}
